﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;

namespace PoliAsis.Domain.Common
{
    [System.AttributeUsage(System.AttributeTargets.Property| AttributeTargets.Field)]
    public class NonPersistent : System.Attribute
    {
        public NonPersistent()
        {
        }
    }

    public static class ExtenionMethods
    {
        public static bool IsNonPersistent(this PropertyInfo pi) 
        {
            object[] attr_list = pi.GetCustomAttributes(true);
            bool is_non_persistent = false;
            if (attr_list != null && attr_list.Length > 0)
            {
                for (int i = 0; i < attr_list.Length; i++)
                {
                    if (attr_list[i] != null && attr_list[i] is NonPersistent)
                    {
                        is_non_persistent = true;
                        break;
                    }
                }
            }

            return is_non_persistent;
        }

    }
}
